<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <%
        String path = request.getContextPath();
        String basePath = request.getScheme() + "://"
                + request.getServerName() + ":" + request.getServerPort()
                + path;
    %>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>图片分享后台</title>
    <!-- 基本配置文件会先放在前面 -->
    <link rel="stylesheet" type="text/css" href="../resources/package/bootstrap/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="../resources/package/Trumbowyg-1.0/trumbowyg/design/css/trumbowyg.css">
    <link rel="stylesheet" type="text/css" href="../resources/manager/css/base.css">
    <link rel="stylesheet" type="text/css" href="../resources/manager/css/info.css">
    <script type="text/javascript" src="../resources/package/jquery/jquery-3.1.1.min.js"></script>
    <script type="text/javascript" src="../resources/package/bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="../resources/package/layer/layer.js"></script>
    <style>
        body{
            padding: 0 30px;
        }
        .control-label {
            margin-bottom: 10px;
            text-align: left;
            font-size: 17px;
            font-weight: 500;
        }

        /*y用于添加公告*/
        .form-group .trumbowyg-box {
            margin: 0 auto;
            width: 100%;
        }
    </style>
    <script>
        $(function () {
            $(".saveSystemInfoBtn").click(function () {
                console.log($(".infoContent").val());
                let that = $(this);
                $.ajax({
                    type: "POST",
                    url: "<%=basePath%>/admin/saveSystemInfo",
                    data: {
                        content: $(".infoContent").val(),
                        publish: $(".publishChecked").is(':checked'),
                    },
                    xhrFields: {
                        withCredentials: true
                    },
                    crossDomain: true,
                    dataType: "json",
                    success: function (data) {
                        console.log(data);
                        layer.msg('保存成功', {
                            time: 500
                        });
//                        window.parent.location.reload();//刷新父页面
                        <%--window.parent.open("<%=basePath%>/admin/info?pn=1","_self");--%>
                    },
                    error: function (data) {
                        console.log(data);
                        layer.msg('保存失败', {
                            time: 500
                        });
                    }
                });
            });
        });
    </script>
</head>
<body>
<%--<form class="form-horizontal" role="form" action="<%=basePath%>/admin/saveSystemInfo" method="post">--%>
<div class="form-group">
    <label for="form-content" class="col-sm-12 control-label">内容：</label>
    <div class="col-sm-12">
        <textarea id="form-content" name="content" class="editor col-lg-12 infoContent" cols="30" rows="10">${content}</textarea>
    </div>
</div>
<div class="form-group">
    <div class="col-sm-12">
        <div class="checkbox" name="public">
            <label>
                <input type="checkbox" class="publishChecked" name="publish"> 发布
            </label>
        </div>
    </div>
</div>
<div class="form-group">
    <div class="col-sm-12">
        <a class="saveSystemInfoBtn">
            <button class="btn btn-default">保存</button>
        </a>
        <button class="btn btn-danger cancelBtn">取消</button>
    </div>
</div>
<%--</form>--%>

</body>
<script type="text/javascript" src="../resources/package/Trumbowyg-1.0/jquery.min.js"></script>
<script type="text/javascript" src="../resources/package/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../resources/package/Trumbowyg-1.0/trumbowyg/trumbowyg.js"></script>
<script type="text/javascript" src="../resources/package/Trumbowyg-1.0/trumbowyg/langs/fr.js"></script>
<script type="text/javascript"
        src="../resources/package/Trumbowyg-1.0/trumbowyg/plugins/upload/trumbowyg.upload.js"></script>
<script type="text/javascript"
        src="../resources/package/Trumbowyg-1.0/trumbowyg/plugins/base64/trumbowyg.base64.js"></script>
<script>
    /** Simple customization with current options **/
    $('#form-content').trumbowyg({
        lang: 'fr',
        closable: true,
        mobile: true,
        fixedBtnPane: true,
        fixedFullWidth: true,
        semantic: true,
        resetCss: true,
        autoAjustHeight: true,
        autogrow: true
    });


    $('.editor').on('dblclick', function (e) {
        $(this).trumbowyg({
            lang: 'fr',
            closable: true,
            fixedBtnPane: true
        });
    });
</script>
</html>